package wechat.rcv.util;

import java.awt.image.BufferedImage;
import java.io.InputStream;
import javax.imageio.ImageIO;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/wechatsqrimage")
@ResponseBody
@SuppressWarnings("all")
public class WechatSqrImageController {
  @RequestMapping(method = RequestMethod.GET)
  public byte[] process(final String sqrfilename) {
    try {
      Class<? extends Object> _class = this.getClass();
      String _plus = ("/" + sqrfilename);
      final InputStream is = _class.getResourceAsStream(_plus);
      final BufferedImage img = ImageIO.read(is);
      ByteArrayOutputStream _byteArrayOutputStream = new ByteArrayOutputStream();
      final ByteArrayOutputStream bao = _byteArrayOutputStream;
      ImageIO.write(img, "jpg", bao);
      return bao.toByteArray();
    } catch (Exception _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
}
